package com.ecoolex.cms.system.ws;

import java.util.List;

import org.apache.dubbo.config.annotation.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.ecoolex.cms.system.core.manager.SunrisedutyfreeApplicationManager;
import com.ecoolex.cms.system.core.manager.TokenManager;
import com.ecoolex.cms.system.core.manager.VRNaviPathManager;
import com.ecoolex.cms.system.core.manager.VRSceneHotspotManager;
import com.ecoolex.cms.system.core.manager.VRSceneHotspotParamManager;
import com.ecoolex.cms.system.core.manager.VRSceneManager;
import com.ecoolex.cms.system.entity.SunrisedutyfreeApplication;
import com.ecoolex.cms.system.entity.VRNaviPath;
import com.ecoolex.cms.system.entity.VRScene;
import com.ecoolex.cms.system.entity.VRSceneHotspot;
import com.ecoolex.cms.system.entity.VRSceneHotspotParam;
import com.ecoolex.cms.system.pojo.CouponDTO;
import com.ecoolex.cms.system.pojo.TokenDTO;
import com.ecoolex.cms.system.ws.contract.IgnitionRequestType;
import com.ecoolex.cms.system.ws.contract.IgnitionResponseType;
import com.ecoolex.framework.common.pojo.BizResult;
import com.ecoolex.framework.common.pojo.Page;
import com.ecoolex.framework.common.pojo.Pagination;


@Service
public class CmsSystemServiceImpl implements CmsSystemService {

	private Logger log = LoggerFactory.getLogger(CmsSystemServiceImpl.class);

	@Override
	public IgnitionResponseType ignition(IgnitionRequestType request) {
		log.info("点火成功");
		return new IgnitionResponseType().setSuccessful();
	}

	@Autowired
	private VRSceneManager vrSceneManager;

	@Override
	public Pagination<VRScene> queryVRScene(Integer userId, String name, Integer[] status, Page page) {
		return vrSceneManager.query(userId, name, status, page);
	}

	@Override
	public VRScene getVRSceneById(Integer userId, Integer sceneId) {
		return vrSceneManager.getById(userId, sceneId);
	}

	@Override
	public VRScene getVRSceneByOpenId(String openId) {
		return vrSceneManager.getByOpenId(openId);
	}

	@Override
	public VRScene addVRScene(VRScene record, String createUser) {
		return vrSceneManager.add(record, createUser);
	}

	@Override
	public VRScene editVRScene(VRScene record, String updateUser) {
		return vrSceneManager.edit(record, updateUser);
	}

	@Override
	public Boolean deleteVRScene(VRScene record, String updateUser) {
		return vrSceneManager.delete(record, updateUser);
	}

	@Override
	public Boolean online(Integer userId, Integer sceneId, String updateUser) {
		return vrSceneManager.online(userId, sceneId, updateUser);
	}

	@Override
	public Boolean offline(Integer userId, Integer sceneId, String updateUser) {
		return vrSceneManager.offline(userId, sceneId, updateUser);
	}

	@Autowired
	private VRSceneHotspotManager vrSceneHotspotManager;

	@Override
	public Pagination<VRSceneHotspot> queryVRSceneHotspot(Integer sceneId, String hotspotName, Page page) {
		return vrSceneHotspotManager.query(sceneId, hotspotName, page);
	}

	@Override
	public List<VRSceneHotspot> queryVRSceneHotspotBySceneId(Integer sceneId) {
		return vrSceneHotspotManager.queryBySceneId(sceneId);
	}

	@Override
	public VRSceneHotspot getVRSceneHotspotById(Integer hotspotId) {
		return vrSceneHotspotManager.getById(hotspotId);
	}

	@Override
	public Boolean deleteVRSceneHotspotById(Integer hotspotId, String updateUser) {
		return vrSceneHotspotManager.deleteById(hotspotId, updateUser);
	}

	@Override
	public VRSceneHotspot addVRSceneHotspot(VRSceneHotspot record, List<VRSceneHotspotParam> paramList, String createUser) {
		return vrSceneHotspotManager.add(record, paramList, createUser);
	}

	@Override
	public VRSceneHotspot editVRSceneHotspot(VRSceneHotspot record, List<VRSceneHotspotParam> paramList, String updateUser) {
		return vrSceneHotspotManager.edit(record, paramList, updateUser);
	}

	@Autowired
	private VRSceneHotspotParamManager vrSceneHotspotParamManager;

	@Override
	public List<VRSceneHotspotParam> queryVRSceneHotspotParamByHotspot(Integer hotspotId) {
		return vrSceneHotspotParamManager.queryByHotspot(hotspotId);
	}

	@Autowired
	private VRNaviPathManager vrNaviPathManager;

	@Override
	public Boolean updateVRNaviPath(VRScene scene, List<VRNaviPath> list, String updateUser) {
		return vrNaviPathManager.update(scene, list, updateUser);
	}

	@Override
	public Long countVRNaviPathByBySceneId(Integer sceneId) {
		return vrNaviPathManager.countByBySceneId(sceneId);
	}

	@Override
	public List<VRNaviPath> queryVRNaviPathBySceneId(Integer sceneId) {
		return vrNaviPathManager.queryBySceneId(sceneId);
	}

	@Autowired
	private SunrisedutyfreeApplicationManager sunrisedutyfreeApplicationManager;

	@Override
	public SunrisedutyfreeApplication getSunrisedutyfreeApplicationByAppidAndSecret(String appId, String secret) {
		return sunrisedutyfreeApplicationManager.getByAppidAndSecret(appId, secret);
	}

	@Autowired
	private TokenManager tokenManager;

	@Override
	public TokenDTO createToken(SunrisedutyfreeApplication application) {
		return tokenManager.createToken(application);
	}

	@Override
	public SunrisedutyfreeApplication getSunrisedutyfreeApplicationByToken(String token) {
		return tokenManager.getSunrisedutyfreeApplicationByToken(token);
	}

	@Autowired
	private com.ecoolex.cms.system.core.external.SunrisedutyfreeApiExternal sunrisedutyfreeApiExternal;

	@Override
	public BizResult<CouponDTO> getCouponDTOBarcode(String token) {
		return sunrisedutyfreeApiExternal.getBarcode(token, null, 1);
	}

}
